﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Five.Models;

namespace Five.Controllers
{
    public class DefaultController : Controller
    {
        Model1 model1 = new Model1();
        // GET: Default
        public ActionResult Index()
        {
            var list = model1.Task.ToList();
            return View(list);
        }
        public ActionResult XiangQing(int id)
        {
            //Request.QueryString["id"];
            Task task = model1.Task.FirstOrDefault(p=>p.TaskID==id);
            return View(task);
        }
        public ActionResult Delete(int id)
        {
            Task task = model1.Task.FirstOrDefault(p => p.TaskID == id);
            if (task != null)
            {
                model1.Task.Remove(task);
                var result = model1.SaveChanges() > 0;
                return Json(result);
            }
            return Json(false);
        }
    }
}